
package com.android.matmanual;

import java.util.ArrayList;

import android.R.string;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class FactoryTestListAdapter extends BaseAdapter {
	
	private Context mContext;
	private final LayoutInflater mLayoutInflater;
	ArrayList<GridViewItems> mItemList;	    
	String[] mStrings;          
	int mCount;
	
	public FactoryTestListAdapter(Context context,String[] string,int count,ArrayList<GridViewItems> items) {
		super();
		mContext = context;
		mCount = count;
		mStrings = string;
		mLayoutInflater = LayoutInflater.from(context);
		mItemList = items;
	}
	
    public int getCount() {
    	return mCount;
    }
	
	
	public Object getItem(int position) {
		return null;
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		final RelativeLayout tv;
		if (convertView == null) {
			//for_girdviewtv = (RelativeLayout) mLayoutInflater.inflate(
			//		R.layout.factory_test_list_item, parent, false);
			 tv = (RelativeLayout) mLayoutInflater.inflate(
						R.layout.factory_test_grid_item, parent, false);
		} else {
			 tv = (RelativeLayout)convertView;
		}
		//for_girdview TextView num = (TextView)tv.findViewById(R.id.num);
		//for girdview num.setText(Integer.toString(position+1));
		TextView name = (TextView)tv.findViewById(R.id.name);
		name.setText(mStrings[position]);
		tv.setTag(position+1);
		
		GridViewItems item = mItemList.get(position);
    if(item.testResult == Const.SUCCESS){
    	name.setTextColor(Color.GREEN);
    }else if(item.testResult == Const.FAIL){
    	name.setTextColor(Color.RED);
    }else{
    	name.setTextColor(Color.WHITE);
    }
    
		return tv;
	}

}
		 